import {Rectangle} from "@/w3ts/handles/rect";

/** @noSelf **/
export default class RectUtil {


    /**
     * 用完记得rect.destroy() 排泄
     * @param centerX
     * @param centerY
     * @param radius
     * @constructor
     */
    static GetRectFromCircle(centerX: number, centerY: number, radius: number): Rectangle {
        return new Rectangle(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
    }

    /**
     * 创建区域
     * @param x
     * @param y
     * @param width
     * @param height
     */
    static createRect(x: number, y: number, width: number, height: number): rect {
        return Rect(x - width * 0.5, y - height * 0.5, x + width * 0.5, y + height * 0.5)
    }

    /**
     * 获取区域内随机坐标
     */
    static getRandomXYInRect(qy: rect): { x: number, y: number } {
        const x = GetRandomInt(GetRectMinX(qy), GetRectMaxX(qy))
        const y = GetRandomInt(GetRectMinY(qy), GetRectMaxY(qy))
        return {x: x, y: y}
    }


}
